package servlet.lifecycle;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class LifeCycleServlet
 */
public class LifeCycleServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

    public LifeCycleServlet() {
    	System.out.println("LifeCycleServlet 생성자 실행");
    }
    
    public void init() {
    	System.out.println("LifeCycleServlet.init() 실행");
    }
    
    
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//GET 요청을 처리하는 service() 메소드 
		doPost(request, response);//GET/POST 요청에 대해 하는 일이 같은 경우. 구현은 한 메소드에서 하고 다른 메소드에서는 호출
	}

	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//POST 요청을 처리하는 service() 메소드
		System.out.println("LifeCycleServlet.service() 실행 - doPost()");
	}
		
	public void destroy(){
		System.out.println("LifeCycleServlet.destroy() 실행");
	}
}
